<%@ page import="com.dzxcqmxm.Dao.impl.PhotoDaoImpl" %>
<%@ page import="com.dzxcqmxm.Dao.PhotoDao" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.dzxcqmxm.JB.Photo" %><%--
  Created by IntelliJ IDEA.
  User: Payboi
  Date: 2022/6/4
  Time: 12:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <style>
        .left{
            width: 80%;
            height: 600px;
            background-color: #BDFDF0;

            float: left;
        }
        .right{
            width: 12%;
            height: 400px;
            background-color: #ADFCEC;
            float: left;
            padding-top: 200px;
        }
        .bt{

            background-color: rgba(155, 243, 236, 0.76);
            width: 100%;
            border-style: hidden;
            border-color: #C4E6D8;
        }
        .in{
            background-color: rgba(212, 241, 239, 0.77);
            width: 100%;
            border-style: double;
            border-color: #80F6DE;
        }
        img{
            width: 100px;
        }
        .photo{
            float:left;
            width: 102px;
            /*设置文本居中就对了！！*/
            text-align:center;
        }

    </style>
</head>
<body>
    <%

    /**
     * 将a设为全局变量好了，会很方便，
     * 然后发现并不行，就离谱
     */
%>
<div>
    <div class="left">
        <h1>这里是展示用户自己新建的照片的页面</h1>
        <%--准备展示照片--%>
        <%
            PhotoDao photoDao = new PhotoDaoImpl();
            ArrayList<Photo> photoArrayList = new ArrayList<Photo>();

            /**
             * 获取servlet页面中的session参数
             */
            photoArrayList = (ArrayList<Photo>) session.getAttribute("photoArrayList");

            System.out.println("测试yhDisplayPhoto.jsp的photoArrayList"+photoArrayList);

            if(photoArrayList!=null&&photoArrayList.size()>0){
                for(Photo photo :photoArrayList){
                    request.setAttribute("PhotoUrl",photo.getPhotoUrl());

        %>
        <div class="photo">
<%--            这里展示的照片应该来自于我们用户上传的照片--%>
<%--            <img src="../img/album.png">--%>
             <img src=/${PhotoUrl}>

            <p><%
                out.println("<tr><td>" +
                        photo.getPhotoName() +
                        "</td></tr><br><br>");
            %></p>
        </div>
        <%
                }
            }
        %>


    </div>
    <div class="right">
        <form action="/dzxc/addPhotoServlet" method="post" enctype="multipart/form-data">
            <% //获取展示照片页面传过来的参数
                String AlbumUrl = (String) request.getSession ().getAttribute ("AlbumUrl");
                String XTXCName = (String) request.getSession ().getAttribute ("XTXCName");
                String AlbumName = (String) request.getSession ().getAttribute ("AlbumName");
                //并且再次设立给增加页面用
                request.getSession().setAttribute("AlbumUrl", AlbumUrl);
                request.getSession().setAttribute("XTXCName", XTXCName);
                request.getSession().setAttribute("AlbumName", AlbumName);

            %>
            <input class="in" type="file" name="fileName"/>
            <input class="in" type="text" name="PhotoName"/>
            <input class="bt" type="submit" value="新建照片"/>
        </form>
        <form action="/dzxc/delPhotoServlet" method="post">
            <% //获取展示照片页面传过来的参数
                String AlbumUrl1 = (String) request.getSession ().getAttribute ("AlbumUrl");
                String XTXCName1 = (String) request.getSession ().getAttribute ("XTXCName");
                String AlbumName1 = (String) request.getSession ().getAttribute ("AlbumName");
                //并且再次设立给增加页面用
                request.getSession().setAttribute("AlbumUrl", AlbumUrl1);
                request.getSession().setAttribute("XTXCName", XTXCName1);
                request.getSession().setAttribute("AlbumName", AlbumName1);
               request.setCharacterEncoding("UTF-8");

            %>
            <input class="in" type="text" name="PhotoName"/>
            <input class="bt" type="submit" value="删除照片"/>
        </form>
        <form action="/dzxc/updatePhotoServlet" method="post">
            <input class="in" type="text" name="PhotoName"/>
            <input class="in" type="text" name="PhotoBaomi"/>
            <input class="bt" type="submit" value="保密性"/>
        </form>
    </div>
</div>

</html>
